package common

type ResCode int64

const(
	CodeSuccess ResCode = 1000 + iota
	CodeUserCreateSuccess
	CodeUserCreateFail
	CodeUserExist
	CodeUserNoExist
	CodeInvalidPassword
	CodeServerBusy
)

var codeMsgMap = map[ResCode]string{
	CodeSuccess:		"success",
	CodeUserCreateSuccess: "用户创建成功",
	CodeUserCreateFail: "用户创建失败",
	CodeUserExist: "用户已存在",
	CodeUserNoExist: "用户不存在",
	CodeInvalidPassword: "用户名或密码错误",
	CodeServerBusy: "服务繁忙",
}

// 通过code获取对应的消息
func (code ResCode) Msg() string {
	msg, ok := codeMsgMap[code]
	if !ok {
		msg = codeMsgMap[CodeServerBusy]
	}
	return msg
}

